package edu.scau.pro.hotel.service.impl;

import edu.scau.pro.hotel.entity.HotelWayDiscount;
import edu.scau.pro.hotel.mapper.HotelWayDiscountMapper;
import edu.scau.pro.hotel.service.IHotelWayDiscountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotelWayDiscount)表服务实现类
 *
 * @author CJW
 * @since 2022-04-24 13:17:26
 */
@Service("hotelWayDiscountService")
public class HotelWayDiscountServiceImpl implements IHotelWayDiscountService {
    @Resource
    private HotelWayDiscountMapper hotelWayDiscountMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param wayDiscountId 主键
     * @return 实例对象
     */
    @Override
    public HotelWayDiscount queryById(Integer wayDiscountId) {
        return this.hotelWayDiscountMapper.queryById(wayDiscountId);
    }

    /**
     * 查询指定行
     *
     * @param hotelWayDiscount 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotelWayDiscount> queryAll(HotelWayDiscount hotelWayDiscount) {
        return this.hotelWayDiscountMapper.queryAll(hotelWayDiscount);
    }

    /**
     * 新增数据
     *
     * @param hotelWayDiscount 实例对象
     * @return 实例对象
     */
    @Override
    public HotelWayDiscount insert(HotelWayDiscount hotelWayDiscount) {
        this.hotelWayDiscountMapper.insert(hotelWayDiscount);
        return hotelWayDiscount;
    }

    /**
     * 修改数据
     *
     * @param hotelWayDiscount 实例对象
     * @return 实例对象
     */
    @Override
    public HotelWayDiscount update(HotelWayDiscount hotelWayDiscount) {
        this.hotelWayDiscountMapper.update(hotelWayDiscount);
        return this.queryById(hotelWayDiscount.getWayDiscountId());
    }

    /**
     * 通过主键删除数据
     *
     * @param wayDiscountId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer wayDiscountId) {
        return this.hotelWayDiscountMapper.deleteById(wayDiscountId) > 0;
    }
}
